package com.yanzhen.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yanzhen.dao.WorkerMapper;
import com.yanzhen.model.Worker;
import com.yanzhen.service.IWorkerService;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author kappy
 * @since 2021-04-29
 */
@Service
public class WorkerServiceImpl extends ServiceImpl<WorkerMapper, Worker> implements IWorkerService {

    @Override
    public IPage<Worker> findListByPage(Integer page, Integer pageCount){
        IPage<Worker> wherePage = new Page<>(page, pageCount);
        Worker where = new Worker();

        return   baseMapper.selectPage(wherePage, Wrappers.query(where));
    }

    @Override
    public int add(Worker worker){
        return baseMapper.insert(worker);
    }

    @Override
    public int delete(Long id){
        return baseMapper.deleteById(id);
    }

    @Override
    public int updateData(Worker worker){
        return baseMapper.updateById(worker);
    }

    @Override
    public Worker findById(Long id){
        return  baseMapper.selectById(id);
    }
}
